<template>
  <div>
    <city-header></city-header>
    <city-search
      :cities="cities"
    ></city-search>
    <city-list
      :hot="hotCities"
      :cities="cities"
      :letter="letter"
    ></city-list>
    <city-alphabet
      :cities="cities"
      @change="changeLetter"
    ></city-alphabet>
  </div>
</template>

<script>
import CityHeader from './components/header'
import CitySearch from './components/search'
import CityList from './components/list'
import CityAlphabet from './components/alphabet'
import axios from 'axios'
export default {
  name: 'City',
  components: {
    CityHeader,
    CitySearch,
    CityList,
    CityAlphabet
  },
  data () {
    return {
      hotCities: [],
      cities: {},
      letter: ''
    }
  },
  methods: {
    getCitys () {
      axios.get('/api/city.json').then(res => {
        console.log(res)
        var rs = res.data
        if (rs.ret && rs.data) {
          const data = rs.data
          this.hotCities = data.hotCities
          this.cities = data.cities
        }
      })
    },
    changeLetter (letter) {
      this.letter = letter
    }
  },
  mounted () {
    this.getCitys()
  }
}
</script>

<style lang="stylus" scoped>

</style>
